#ifndef _FUNCTIONS_H_
#define _FUNCTIONS_H_

SDL_Surface* Init(int width, int height, int bpp, std::string caption)
{
        if(SDL_Init(SDL_INIT_EVERYTHING)==-1)
        {
            cout<<"SDL Not initialized"<<endl;
            return NULL;
        }
        SDL_Surface* screen=SDL_SetVideoMode(width,height,bpp,SDL_SWSURFACE);
        if(screen==NULL)
        {
            return NULL;
        }
        SDL_WM_SetCaption(caption.c_str(), NULL);
	   return screen;
}

SDL_Surface *loadImage( std::string filename ) 
{
    SDL_Surface* load = NULL;
    SDL_Surface* img = NULL;
    load = IMG_Load( filename.c_str() );
    if( load != NULL )
    {
        img = SDL_DisplayFormat( load );
        SDL_FreeSurface( load );
        if( img != NULL )
        {
            Uint32 alpha = SDL_MapRGB( img->format, 0xFF, 0xFF, 0xFE );
            SDL_SetColorKey( img, SDL_SRCCOLORKEY, alpha );
        }
    }
    return img;
}

void blit(int x, int y, SDL_Surface* srf, SDL_Surface* dest)
{
	   SDL_Rect s;
	   s.x=x;
	   s.y=y;	   
	   SDL_BlitSurface(srf,NULL,dest,&s);
}

string to_string(int convert)
{
	stringstream out;
	out<<convert;
	return out.str();
}

#endif
